package com.training.server;

import com.training.client.Handler;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * Created by Ywen on 2018/12/27.
 */
public class SimpleServer {
    private ServerSocket serverSocket;
    private int port = 8080;

    public SimpleServer() {
        try {
            serverSocket = new ServerSocket(port);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void run() {
        try {
            while (true) {
                Socket socket = serverSocket.accept();
                new Handler(socket).run();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        new SimpleServer().run();
    }
}
